// pages/x_backgroundaudio2/x_backgroundaudio2.js
const backgroundAudioManager =  wx.getBackgroundAudioManager()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    note:'',
    num:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    backgroundAudioManager.title = '此时此刻'
    backgroundAudioManager.epname = '此时此刻'
    backgroundAudioManager.singer = '许巍'
    backgroundAudioManager.coverImgUrl = 'http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000'
    backgroundAudioManager.src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46'
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  xplay:function(){
    
    backgroundAudioManager.play()
    var that = this
    backgroundAudioManager.onCanplay({
      callback:function(){
        that.setData({
          note: '开始了'
        })
      }
      
    })

    backgroundAudioManager.onPlay({
      callback: function () {
        that.setData({
          num:19 /*backgroundAudioManager.currentTime*/
        })
      }
    } )


  },
  xpause:function(){
    backgroundAudioManager.pause()

    backgroundAudioManager.onPause({
      callback: function () {
        that.setData({
          num: 19 /*backgroundAudioManager.currentTime*/
        })
      }
    })
  },
  xseek:function(){
    backgroundAudioManager.seek(28)
  },
  xstop:function(){
    backgroundAudioManager.stop()
  }
})